package com.molin.networkTest.socketTest.demo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Demo1 {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress inetAddress=InetAddress.getByName("DESKTOP-VDHQ0JD");
        String hostname=inetAddress.getHostName();
        String ip=inetAddress.getHostAddress();
        System.out.println("主机名为： "+hostname+"，IP地址为： "+ip);
    }
}
